package com.lw.reflection;

/**
 * @author LW
 * @2020/9/22 14:47
 */
public class Test06 {
    public static void main(String[] args) throws ClassNotFoundException {
        //获取系统类的 加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);//sun.misc.Launcher$AppClassLoader@18b4aac2

        //获取系统类加载器的父类加载器-->扩展类加载器
        ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);//sun.misc.Launcher$ExtClassLoader@677327b6

        //获取扩展类加载器的父类加载器-->根加载器（C/C++）
        ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);//用来装载核心类库。该加载器无法被获取

        //测试当前类是那个加载器加载的
        ClassLoader classLoader = Class.forName("com.lw.reflection.Test06").getClassLoader();
        System.out.println(classLoader);

        //测试JDK内置的类是谁加载的
        ClassLoader classLoader1 = Class.forName("java.lang.Object").getClassLoader();
        System.out.println(classLoader1);

        //如何获得系统类加载器可以加载的路径
        System.out.println(System.getProperty("java.class.path"));
        //C:\Program Files\Java\jdk1.8.0_221\jre\lib\charsets.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\deploy.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\access-bridge-64.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\cldrdata.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\dnsns.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\jaccess.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\jfxrt.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\localedata.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\mysql-connector-java-8.0.17.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\nashorn.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\sunec.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\sunjce_provider.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\sunmscapi.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\sunpkcs11.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\ext\zipfs.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\javaws.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\jce.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\jfr.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\jfxswt.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\jsse.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\management-agent.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\plugin.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\resources.jar;
        // C:\Program Files\Java\jdk1.8.0_221\jre\lib\rt.jar;
        // C:\Users\ASUS\.IntelliJIdea2019.3\注解和反射\target\classes;
        // D:\IntelliJ IDEA 2019.3.3\lib\idea_rt.jar
    }
}
